package com.yn.service.zy.model.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.yn.common.constants.Constants;
import com.yn.common.enums.AuditStatusEnum;
import com.yn.common.enums.BooleanEnum;
import com.yn.common.enums.CarFleetTypeEnum;
import com.yn.common.model.zy.TCarFleetManageDO;
import com.yn.common.response.driver.TCarManageResponse;
import com.yn.common.utils.BeanUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.ObjectUtils;

import java.util.Date;
import java.util.List;

/**
 * @ClassName: TCarFleetManageDTO
 * @Description:
 * @Author: lxp
 * @Date: 2025/5/8 16:42
 **/
@Data
@ApiModel("车队出参")
public class TCarFleetManageDTO {
    @ApiModelProperty("主键id")
    private Integer id;

    @ApiModelProperty("车队类型(1:个人 2：车队)")
    private Integer fleetType;

    @ApiModelProperty("车队类型字符")
    private String fleetTypeStr;

    @ApiModelProperty("车队名称")
    private String fleetName;

    @ApiModelProperty("车队图片")
    private String fleetImageUrl;

    @ApiModelProperty("车队简介")
    private String fleetIntro;

    @ApiModelProperty("车队负责姓名")
    private String fleetCuratorName;

    @ApiModelProperty("车队负责手机号")
    private String fleetCuratorPhonenumber;

    @ApiModelProperty("车队负责身份证")
    private String fleetCuratorIdNumber;

    @ApiModelProperty("运营资格材料")
    private String operationMaterial;

    @ApiModelProperty("审核状态(0:审核中 1:审核通过 3:审核不通过)")
    private Integer auditStatus;

    @ApiModelProperty("审核状态字符")
    private String auditStatusStr;

    @ApiModelProperty("岗位状态(0:非在岗 1:在岗)")
    private Integer postStatus;

    @ApiModelProperty("岗位状态字符")
    private String postStatusStr;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = Constants.DATE_FORMAT)
    private Date createTime;

    @ApiModelProperty("车队司机信息")
    private List<TCarManageResponse> carManageDTOList;

    public static TCarFleetManageDTO transform(TCarFleetManageDO tCarFleetManageDO){
        if (ObjectUtils.isEmpty(tCarFleetManageDO)) {
            return null;
        }

        TCarFleetManageDTO tCarFleetManageDTO = BeanUtils.copyProperties(tCarFleetManageDO, TCarFleetManageDTO.class);

        if (!ObjectUtils.isEmpty(tCarFleetManageDTO.getFleetType())) {
            CarFleetTypeEnum carFleetTypeEnum = CarFleetTypeEnum.getByCode(tCarFleetManageDTO.getFleetType());
            if (!ObjectUtils.isEmpty(carFleetTypeEnum)) {
                tCarFleetManageDTO.setFleetTypeStr(carFleetTypeEnum.getName());
            }
        }

        if (!ObjectUtils.isEmpty(tCarFleetManageDTO.getAuditStatus())) {
            AuditStatusEnum auditStatusEnum = AuditStatusEnum.getByCode(tCarFleetManageDTO.getAuditStatus());
            if (!ObjectUtils.isEmpty(auditStatusEnum)) {
                tCarFleetManageDTO.setAuditStatusStr(auditStatusEnum.getName());
            }
        }

        if (!ObjectUtils.isEmpty(tCarFleetManageDTO.getPostStatus())) {
            BooleanEnum booleanEnum = BooleanEnum.getByCode(tCarFleetManageDTO.getPostStatus());
            if (!ObjectUtils.isEmpty(booleanEnum)) {
                tCarFleetManageDTO.setPostStatusStr(booleanEnum.getName());
            }
        }

        return tCarFleetManageDTO;
    }
}
